package com.pz.mapper;

import com.pz.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author：PZ
 * @Date: 2020/11/3 19 02
 */
/**
 * @description user
 * @author starp
 * @date 2021-11-04
 */
//@Mapper
//@Repository
public interface UserMapper {


    @Results(value = {
            @Result(property = "name", column = "name"),
            @Result(property = "password", column = "password")
    })
    @Select(value = "select * from user where user_id=#{queryParam}")
    User selectOne(String queryParam);

    @Results(value = {
            @Result(property = "name", column = "name"),
            @Result(property = "password", column = "password")
    })
    @Select(value = "select * from user where "
            +" name=#{name} or "
            +" password=#{password}"
    )
    List<User> selectList(User user);

    /**
     * 根据条件查询用户
     *
     * @param map
     * @return
     */
    User findUserByCondition(Map<String, Object> map);


    /**
     * 新增
     * @author starp
     * @date 2021/11/04
     **/
    int insert(User user);

    /**
     * 刪除
     * @author starp
     * @date 2021/11/04
     **/
    int delete(int id);

    /**
     * 更新
     * @author starp
     * @date 2021/11/04
     **/
    int update(User user);

    /**
     * 查询 根据主键 id 查询
     * @author starp
     * @date 2021/11/04
     **/
    User load(int id);

    /**
     * 查询 分页查询
     * @author starp
     * @date 2021/11/04
     **/
    List<User> pageList(int offset,int pagesize);

    /**
     * 查询 分页查询 count
     * @author starp
     * @date 2021/11/04
     **/
    int pageListCount(int offset,int pagesize);
}
